renamed ReadOK to gif_read. Added a lot of comments to the file.
authorJonathan Blandford <jrb@redhat.com>
Wed, 3 Nov 1999 23:22:27 +0000 (23:22 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Wed, 3 Nov 1999 23:22:27 +0000 (23:22 +0000)
1999-11-03  Jonathan Blandford  <jrb@redhat.com>

* src/io-gif.c (gif_read): renamed ReadOK to gif_read.
Added a lot of comments to the file.

gdk-pixbuf/ChangeLog
gdk-pixbuf/io-gif.c

index 2235588b160b3706ee21798aac37fa0467520eb3..9201c864b20096924cb174cde96748dc5f156783 100644 (file)
@@ -1,5 +1,8 @@
 1999-11-03  Jonathan Blandford  <jrb@redhat.com>
 
+       * src/io-gif.c (gif_read): renamed ReadOK to gif_read.
+       Added a lot of comments to the file.
+
        * src/Makefile.am (libpixbuf_gif_la_LIBADD): Remove dependency on
        lib*gif!!!!
 
index 630672f7b90c2091a1390790409b71733da4591b..e3dfdb81e67f545d2a879ce5963e62254c8dbc58 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+/* This loader is very hairy code.
+ *
+ * The main loop was not designed for incremental loading, so when it was hacked
+ * in it got a bit messy.  Basicly, every function is written to expect a failed
+ * read_gif, and lets you call it again assuming that the bytes are there.
+ *
+ * A note on Animations:
+ * It actually wouldn't be that hard to add support for Gif Animations.  You'd
+ * need, of course, to get the necessary info from the extension, and read the
+ * private colormap into it's own frame, instead of context->color_map.  You'd
+ * also need to stop it from moving to GIF_DONE at the end of gif_get_lzw, (and
+ * of course generate the necessary frames.
+ *
+ * Return vals.
+ * Unless otherwise specified, these are the return vals for most functions:
+ *
+ *  0 -> success
+ * -1 -> more bytes needed.
+ * -2 -> failure; abort the load
+ * -3 -> control needs to be passed back to the main loop
+ *        \_ (most of the time returning 0 will get this, but not always)
+ * >1 -> for functions that get a guchar, the char will be returned.
+ *
+ * -jrb (11/03/1999)
+ */
+
+/*
+ * If you have any images that crash this code, please, please let me know and
+ * send them to me.
+ *                                            <jrb@redhat.com>
+ */
+
 #include <config.h>
 #include <stdio.h>
 #include <glib.h>
@@ -144,10 +176,10 @@ static int GetDataBlock (GifContext *, unsigned char *);
 static int count = 0;
 #endif
 
-/* Returns TRUE if Read is OK,
+/* Returns TRUE if read is OK,
  * FALSE if more memory is needed. */
 static int
-ReadOK (GifContext *context, guchar *buffer, size_t len)
+gif_read (GifContext *context, guchar *buffer, size_t len)
 {
        gint retval;
 #ifdef IO_GIFDEBUG
@@ -194,18 +226,6 @@ ReadOK (GifContext *context, guchar *buffer, size_t len)
 }
 
 
-/*
- * Return vals.
- * Unless otherwise specified, these are the return vals for most functions:
- *
- *  0 -> success
- * -1 -> more bytes needed.
- * -2 -> failure; abort the load
- * -3 -> control needs to be passed back to the main loop
- *        \_ (most of the time returning 0 will get this, but not always)
- */
-
-
 
 /* Changes the stage to be GIF_GET_COLORMAP */
 static void
@@ -230,7 +250,7 @@ gif_get_colormap (GifContext *context)
        unsigned char rgb[3];
 
        while (context->colormap_index < context->bit_pixel) {
-               if (!ReadOK (context, rgb, sizeof (rgb))) {
+               if (!gif_read (context, rgb, sizeof (rgb))) {
                        /*g_message (_("GIF: bad colormap\n"));*/
                        return -1;
                }
@@ -264,7 +284,7 @@ get_data_block (GifContext *context,
 {
 
        if (context->block_count == 0) {
-               if (!ReadOK (context, &context->block_count, 1)) {
+               if (!gif_read (context, &context->block_count, 1)) {
                        return -1;
                }
        }
@@ -275,7 +295,7 @@ get_data_block (GifContext *context,
                        return 0;
                }
 
-       if (!ReadOK (context, buf, context->block_count)) {
+       if (!gif_read (context, buf, context->block_count)) {
                return -1;
        }
 
@@ -302,7 +322,7 @@ gif_get_extension (GifContext *context)
                if (context->extension_label == 0) {
                        /* I guess bad things can happen if we have an extension of 0 )-: */
                        /* I should look into this sometime */
-                       if (!ReadOK (context, & context->extension_label , 1)) {
+                       if (!gif_read (context, & context->extension_label , 1)) {
                                return -1;
                        }
                }
@@ -349,14 +369,14 @@ GetDataBlock (GifContext *context,
 {
 //     unsigned char count;
 
-       if (!ReadOK (context, &context->block_count, 1)) {
+       if (!gif_read (context, &context->block_count, 1)) {
                /*g_message (_("GIF: error in getting DataBlock size\n"));*/
                return -1;
        }
 
        ZeroDataBlock = context->block_count == 0;
 
-       if ((context->block_count != 0) && (!ReadOK (context, buf, context->block_count))) {
+       if ((context->block_count != 0) && (!gif_read (context, buf, context->block_count))) {
                /*g_message (_("GIF: error in reading DataBlock\n"));*/
                return -1;
        }
@@ -715,7 +735,7 @@ gif_prepare_lzw (GifContext *context)
 {
        gint i;
 
-       if (!ReadOK (context, &(context->lzw_set_code_size), 1)) {
+       if (!gif_read (context, &(context->lzw_set_code_size), 1)) {
                /*g_message (_("GIF: EOF / read error on image data\n"));*/
                return -1;
        }
@@ -751,7 +771,7 @@ gif_init (GifContext *context)
        unsigned char buf[16];
        char version[4];
 
-       if (!ReadOK (context, buf, 6)) {
+       if (!gif_read (context, buf, 6)) {
                /* Unable to read magic number */
                return -1;
        }
@@ -770,7 +790,7 @@ gif_init (GifContext *context)
        }
 
        /* read the screen descriptor */
-       if (!ReadOK (context, buf, 7)) {
+       if (!gif_read (context, buf, 7)) {
                /* Failed to read screen descriptor */
                return -1;
        }
@@ -801,7 +821,7 @@ static gint
 gif_get_frame_info (GifContext *context)
 {
        unsigned char buf[9];
-       if (!ReadOK (context, buf, 9)) {
+       if (!gif_read (context, buf, 9)) {
                return -1;
        }
        /* Okay, we got all the info we need.  Lets record it */
@@ -833,7 +853,7 @@ gif_get_next_step (GifContext *context)
 {
        unsigned char c;
        while (TRUE) {
-               if (!ReadOK (context, &c, 1)) {
+               if (!gif_read (context, &c, 1)) {
                        return -1;
                }
                if (c == ';') {